\(\int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx\) [308]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [C] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 34, antiderivative size = 81 \[ \int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=-\frac {a B x}{b^2}+\frac {a^3 B x}{b^2 \left (a^2+b^2\right )}-\frac {B \log (\cos (c+d x))}{b d}+\frac {a^2 B \log (a \cos (c+d x)+b \sin (c+d x))}{b \left (a^2+b^2\right ) d} \]

[Out]

-a*B*x/b^2+a^3*B*x/b^2/(a^2+b^2)-B*ln(cos(d*x+c))/b/d+a^2*B*ln(a*cos(d*x+c)+b*sin(d*x+c))/b/(a^2+b^2)/d

Rubi [A] (verified)

Time = 0.14 (sec) , antiderivative size = 81, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.147, Rules used = {21, 3622, 3556, 3565, 3611} \[ \int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\frac {a^2 B \log (a \cos (c+d x)+b \sin (c+d x))}{b d \left (a^2+b^2\right )}+\frac {a^3 B x}{b^2 \left (a^2+b^2\right )}-\frac {a B x}{b^2}-\frac {B \log (\cos (c+d x))}{b d} \]

[In]

Int[(Tan[c + d*x]^2*(a*B + b*B*Tan[c + d*x]))/(a + b*Tan[c + d*x])^2,x]

[Out]

-((a*B*x)/b^2) + (a^3*B*x)/(b^2*(a^2 + b^2)) - (B*Log[Cos[c + d*x]])/(b*d) + (a^2*B*Log[a*Cos[c + d*x] + b*Sin
[c + d*x]])/(b*(a^2 + b^2)*d)

Rule 21

Int[(u_.)*((a_) + (b_.)*(v_))^(m_.)*((c_) + (d_.)*(v_))^(n_.), x_Symbol] :> Dist[(b/d)^m, Int[u*(c + d*v)^(m +
 n), x], x] /; FreeQ[{a, b, c, d, n}, x] && EqQ[b*c - a*d, 0] && IntegerQ[m] && ( !IntegerQ[n] || SimplerQ[c +
 d*x, a + b*x])

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3565

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Simp[a*(x/(a^2 + b^2)), x] + Dist[b/(a^2 + b^2),
 Int[(b - a*Tan[c + d*x])/(a + b*Tan[c + d*x]), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 + b^2, 0]

Rule 3611

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c/(b*f))
*Log[RemoveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rule 3622

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*(2*
b*c - a*d)*(x/b^2), x] + (Dist[d^2/b, Int[Tan[e + f*x], x], x] + Dist[(b*c - a*d)^2/b^2, Int[1/(a + b*Tan[e +
f*x]), x], x]) /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = B \int \frac {\tan ^2(c+d x)}{a+b \tan (c+d x)} \, dx \\ & = -\frac {a B x}{b^2}+\frac {\left (a^2 B\right ) \int \frac {1}{a+b \tan (c+d x)} \, dx}{b^2}+\frac {B \int \tan (c+d x) \, dx}{b} \\ & = -\frac {a B x}{b^2}+\frac {a^3 B x}{b^2 \left (a^2+b^2\right )}-\frac {B \log (\cos (c+d x))}{b d}+\frac {\left (a^2 B\right ) \int \frac {b-a \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{b \left (a^2+b^2\right )} \\ & = -\frac {a B x}{b^2}+\frac {a^3 B x}{b^2 \left (a^2+b^2\right )}-\frac {B \log (\cos (c+d x))}{b d}+\frac {a^2 B \log (a \cos (c+d x)+b \sin (c+d x))}{b \left (a^2+b^2\right ) d} \\ \end{align*}

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.04 (sec) , antiderivative size = 79, normalized size of antiderivative = 0.98 \[ \int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\frac {B \left (b (i a+b) \log (i-\tan (c+d x))+b (-i a+b) \log (i+\tan (c+d x))+2 a^2 \log (a+b \tan (c+d x))\right )}{2 b \left (a^2+b^2\right ) d} \]

[In]

Integrate[(Tan[c + d*x]^2*(a*B + b*B*Tan[c + d*x]))/(a + b*Tan[c + d*x])^2,x]

[Out]

(B*(b*(I*a + b)*Log[I - Tan[c + d*x]] + b*((-I)*a + b)*Log[I + Tan[c + d*x]] + 2*a^2*Log[a + b*Tan[c + d*x]]))
/(2*b*(a^2 + b^2)*d)

Maple [A] (verified)

Time = 0.06 (sec) , antiderivative size = 59, normalized size of antiderivative = 0.73

method result size
parallelrisch \(\frac {-2 B a b d x +B \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) b^{2}+2 B \ln \left (a +b \tan \left (d x +c \right )\right ) a^{2}}{2 b d \left (a^{2}+b^{2}\right )}\) \(59\)
derivativedivides \(\frac {B \left (\frac {\frac {b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}-a \arctan \left (\tan \left (d x +c \right )\right )}{a^{2}+b^{2}}+\frac {a^{2} \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right ) b}\right )}{d}\) \(69\)
default \(\frac {B \left (\frac {\frac {b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}-a \arctan \left (\tan \left (d x +c \right )\right )}{a^{2}+b^{2}}+\frac {a^{2} \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right ) b}\right )}{d}\) \(69\)
norman \(\frac {-\frac {B \,a^{2} x}{a^{2}+b^{2}}-\frac {b B a x \tan \left (d x +c \right )}{a^{2}+b^{2}}}{a +b \tan \left (d x +c \right )}+\frac {B \,a^{2} \ln \left (a +b \tan \left (d x +c \right )\right )}{b d \left (a^{2}+b^{2}\right )}+\frac {B b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \left (a^{2}+b^{2}\right )}\) \(111\)
risch \(\frac {x B}{i b -a}+\frac {2 i B x}{b}+\frac {2 i B c}{b d}-\frac {2 i a^{2} B x}{b \left (a^{2}+b^{2}\right )}-\frac {2 i a^{2} B c}{b d \left (a^{2}+b^{2}\right )}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{b d}+\frac {a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) B}{b d \left (a^{2}+b^{2}\right )}\) \(147\)

[In]

int(tan(d*x+c)^2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/2*(-2*B*a*b*d*x+B*ln(1+tan(d*x+c)^2)*b^2+2*B*ln(a+b*tan(d*x+c))*a^2)/b/d/(a^2+b^2)

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.17 \[ \int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=-\frac {2 \, B a b d x - B a^{2} \log \left (\frac {b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) + {\left (B a^{2} + B b^{2}\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right )}{2 \, {\left (a^{2} b + b^{3}\right )} d} \]

[In]

integrate(tan(d*x+c)^2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/2*(2*B*a*b*d*x - B*a^2*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d*x + c) + a^2)/(tan(d*x + c)^2 + 1)) + (B*a^2 +
 B*b^2)*log(1/(tan(d*x + c)^2 + 1)))/((a^2*b + b^3)*d)

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.74 (sec) , antiderivative size = 442, normalized size of antiderivative = 5.46 \[ \int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\begin {cases} \tilde {\infty } B x \tan {\left (c \right )} & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {B \left (- x + \frac {\tan {\left (c + d x \right )}}{d}\right )}{a} & \text {for}\: b = 0 \\\frac {i B d x \tan {\left (c + d x \right )}}{2 b d \tan {\left (c + d x \right )} - 2 i b d} + \frac {B d x}{2 b d \tan {\left (c + d x \right )} - 2 i b d} + \frac {B \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )} \tan {\left (c + d x \right )}}{2 b d \tan {\left (c + d x \right )} - 2 i b d} - \frac {i B \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 b d \tan {\left (c + d x \right )} - 2 i b d} - \frac {i B}{2 b d \tan {\left (c + d x \right )} - 2 i b d} & \text {for}\: a = - i b \\- \frac {i B d x \tan {\left (c + d x \right )}}{2 b d \tan {\left (c + d x \right )} + 2 i b d} + \frac {B d x}{2 b d \tan {\left (c + d x \right )} + 2 i b d} + \frac {B \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )} \tan {\left (c + d x \right )}}{2 b d \tan {\left (c + d x \right )} + 2 i b d} + \frac {i B \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 b d \tan {\left (c + d x \right )} + 2 i b d} + \frac {i B}{2 b d \tan {\left (c + d x \right )} + 2 i b d} & \text {for}\: a = i b \\\frac {x \left (B a + B b \tan {\left (c \right )}\right ) \tan ^{2}{\left (c \right )}}{\left (a + b \tan {\left (c \right )}\right )^{2}} & \text {for}\: d = 0 \\\frac {2 B a^{2} \log {\left (\frac {a}{b} + \tan {\left (c + d x \right )} \right )}}{2 a^{2} b d + 2 b^{3} d} - \frac {2 B a b d x}{2 a^{2} b d + 2 b^{3} d} + \frac {B b^{2} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 a^{2} b d + 2 b^{3} d} & \text {otherwise} \end {cases} \]

[In]

integrate(tan(d*x+c)**2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))**2,x)

[Out]

Piecewise((zoo*B*x*tan(c), Eq(a, 0) & Eq(b, 0) & Eq(d, 0)), (B*(-x + tan(c + d*x)/d)/a, Eq(b, 0)), (I*B*d*x*ta
n(c + d*x)/(2*b*d*tan(c + d*x) - 2*I*b*d) + B*d*x/(2*b*d*tan(c + d*x) - 2*I*b*d) + B*log(tan(c + d*x)**2 + 1)*
tan(c + d*x)/(2*b*d*tan(c + d*x) - 2*I*b*d) - I*B*log(tan(c + d*x)**2 + 1)/(2*b*d*tan(c + d*x) - 2*I*b*d) - I*
B/(2*b*d*tan(c + d*x) - 2*I*b*d), Eq(a, -I*b)), (-I*B*d*x*tan(c + d*x)/(2*b*d*tan(c + d*x) + 2*I*b*d) + B*d*x/
(2*b*d*tan(c + d*x) + 2*I*b*d) + B*log(tan(c + d*x)**2 + 1)*tan(c + d*x)/(2*b*d*tan(c + d*x) + 2*I*b*d) + I*B*
log(tan(c + d*x)**2 + 1)/(2*b*d*tan(c + d*x) + 2*I*b*d) + I*B/(2*b*d*tan(c + d*x) + 2*I*b*d), Eq(a, I*b)), (x*
(B*a + B*b*tan(c))*tan(c)**2/(a + b*tan(c))**2, Eq(d, 0)), (2*B*a**2*log(a/b + tan(c + d*x))/(2*a**2*b*d + 2*b
**3*d) - 2*B*a*b*d*x/(2*a**2*b*d + 2*b**3*d) + B*b**2*log(tan(c + d*x)**2 + 1)/(2*a**2*b*d + 2*b**3*d), True))

Maxima [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 75, normalized size of antiderivative = 0.93 \[ \int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\frac {\frac {2 \, B a^{2} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{2} b + b^{3}} - \frac {2 \, {\left (d x + c\right )} B a}{a^{2} + b^{2}} + \frac {B b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{2} + b^{2}}}{2 \, d} \]

[In]

integrate(tan(d*x+c)^2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/2*(2*B*a^2*log(b*tan(d*x + c) + a)/(a^2*b + b^3) - 2*(d*x + c)*B*a/(a^2 + b^2) + B*b*log(tan(d*x + c)^2 + 1)
/(a^2 + b^2))/d

Giac [A] (verification not implemented)

none

Time = 0.51 (sec) , antiderivative size = 76, normalized size of antiderivative = 0.94 \[ \int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\frac {\frac {2 \, B a^{2} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{2} b + b^{3}} - \frac {2 \, {\left (d x + c\right )} B a}{a^{2} + b^{2}} + \frac {B b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{2} + b^{2}}}{2 \, d} \]

[In]

integrate(tan(d*x+c)^2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/2*(2*B*a^2*log(abs(b*tan(d*x + c) + a))/(a^2*b + b^3) - 2*(d*x + c)*B*a/(a^2 + b^2) + B*b*log(tan(d*x + c)^2
 + 1)/(a^2 + b^2))/d

Mupad [B] (verification not implemented)

Time = 7.36 (sec) , antiderivative size = 81, normalized size of antiderivative = 1.00 \[ \int \frac {\tan ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\frac {B\,\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )}{2\,d\,\left (b+a\,1{}\mathrm {i}\right )}+\frac {B\,a^2\,\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}{b\,d\,\left (a^2+b^2\right )}+\frac {B\,\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,1{}\mathrm {i}}{2\,d\,\left (a+b\,1{}\mathrm {i}\right )} \]

[In]

int((tan(c + d*x)^2*(B*a + B*b*tan(c + d*x)))/(a + b*tan(c + d*x))^2,x)

[Out]

(B*log(tan(c + d*x) - 1i)*1i)/(2*d*(a + b*1i)) + (B*log(tan(c + d*x) + 1i))/(2*d*(a*1i + b)) + (B*a^2*log(a +
b*tan(c + d*x)))/(b*d*(a^2 + b^2))